﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IFRS.Web;
using IFRS.DataAccess.DAL;
using System.Data;
using IFRS.Models;
using IFRS_Global;
using System.Globalization;

public partial class IFRS_WIN22_3V : PageBase
{
    #region "---------- Property -----------"

    private FeeAndCostType FeeAndCostType = new FeeAndCostType();
    private SPR_FEEANDCOSTTYPE SPR_FEEANDCOSTTYPE = new SPR_FEEANDCOSTTYPE();

    #endregion

    #region === Event ===

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitPage();
            SetControl();
            if (Request.QueryString["id"].ToString() != null)
                this.BindData(Convert.ToInt32(Request.QueryString["id"].ToString()));
        }
    }

    protected void btnCANCEL_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/IFRS/WIN22_1S.aspx");
    }

    #endregion

    #region === Method ===

    private void InitPage()
    {
        MenuTitleBar = Resources.ifrsMenu.WIN22_3V;
    }

    private void SetControl()
    {
        SetControlReadOnly(form_control);
    }

    private void BindData(int ID)
    {
        var SPR_FEEANDCOSTTYPE = new SPR_FEEANDCOSTTYPE();
        DataTable dtFEEANDCOSTTYPE = SPR_FEEANDCOSTTYPE.SEARCH_BYID(ID);
        List<FeeAndCostType> FeeAndCostType = new List<FeeAndCostType>();
        ConvertHelper.ConvertDataTableToObject(dtFEEANDCOSTTYPE, FeeAndCostType);
        if (dtFEEANDCOSTTYPE.Rows.Count > 0)
        {
            txtFeeAndCostTypeCode.Text = FeeAndCostType[0].FeeAndCostTypeCode;
            txtFeeAndCostType.Text = FeeAndCostType[0].FeeAndCostTypeName;

            if (FeeAndCostType[0].DataType == 1)
                radDataType1.Checked = true;
            else if (FeeAndCostType[0].DataType == 2)
                radDataType2.Checked = true;

            if (FeeAndCostType[0].IsIncludeAmortizeCost == true)
                radAmortizeCost1.Checked = true;
            else if (FeeAndCostType[0].IsIncludeAmortizeCost == false)
                radAmortizeCost2.Checked = true;
        }
    }

    #endregion
}